package com.awise.app.more.activity;

import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.awise.R;
import com.awise.app.cloudy.activity.CloudyActivity;
import com.awise.app.lighting.activity.LightingActivity;
import com.awise.app.manual.activity.ManualActivity;
import com.awise.app.sunrise.activity.SunriseActivity;
import com.awise.app.timer.activity.TimerActivity;
import com.awise.base.BaseActivity;


/**
 * Created by lgz on 2018/1/23.
 */

public class DemoActivity extends BaseActivity implements View.OnClickListener {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.more_demo_layout);
        initView();
    }

    private void initView() {
        TextView s_back = (TextView) this.findViewById(R.id.tv_back);
        s_back.setVisibility(View.VISIBLE);
        s_back.setOnClickListener(this);
        TextView textView_content = (TextView) this.findViewById(R.id.textView_content);
        textView_content.setText(R.string.show_function);
        //演示手动模式
        RelativeLayout most_demo_manual = (RelativeLayout) this.findViewById(R.id.most_demo_manual);
        ImageView most_demo_manual_image=  (ImageView) most_demo_manual.findViewById(R.id.iv_icom_pic);
        most_demo_manual_image.setVisibility(View.GONE);
        TextView most_demo_manual_name=  (TextView) most_demo_manual.findViewById(R.id.most_tv_name);
        most_demo_manual_name.setText(R.string.most_demo_manual);
        most_demo_manual.setOnClickListener(this);
        //演示云彩模式
        RelativeLayout most_demo_cloudy = (RelativeLayout) this.findViewById(R.id.most_demo_cloudy);
        ImageView most_demo_cloudy_image=   (ImageView) most_demo_cloudy.findViewById(R.id.iv_icom_pic);
        most_demo_cloudy_image.setVisibility(View.GONE);
        TextView most_demo_cloudy_name=  (TextView) most_demo_cloudy.findViewById(R.id.most_tv_name);
        most_demo_cloudy_name.setText(R.string.most_demo_cloudy);
        most_demo_cloudy.setOnClickListener(this);
        //演示灯光模式
        RelativeLayout most_demo_lighting = (RelativeLayout) this.findViewById(R.id.most_demo_lighting);
        ImageView most_demo_lighting_image=   (ImageView) most_demo_lighting.findViewById(R.id.iv_icom_pic);
        most_demo_lighting_image.setVisibility(View.GONE);
        TextView most_demo_lighting_name=  (TextView) most_demo_lighting.findViewById(R.id.most_tv_name);
        most_demo_lighting_name.setText(R.string.most_demo_lighting);
        most_demo_lighting.setOnClickListener(this);
        //演示日出日落模式
        RelativeLayout most_demo_sunrise = (RelativeLayout) this.findViewById(R.id.most_demo_sunrise);
        ImageView most_demo_sunrise_image=   (ImageView) most_demo_sunrise.findViewById(R.id.iv_icom_pic);
        most_demo_sunrise_image.setVisibility(View.GONE);
        TextView most_demo_sunrise_name=  (TextView) most_demo_sunrise.findViewById(R.id.most_tv_name);
        most_demo_sunrise_name.setText(R.string.most_demo_sunrise);
        most_demo_sunrise.setOnClickListener(this);
        //演示定时模式模式
        RelativeLayout most_demo_timer = (RelativeLayout) this.findViewById(R.id.most_demo_timer);
        ImageView most_demo_timer_image=   (ImageView) most_demo_timer.findViewById(R.id.iv_icom_pic);
        most_demo_timer_image.setVisibility(View.GONE);
        TextView most_demo_timer_name=  (TextView) most_demo_timer.findViewById(R.id.most_tv_name);
        most_demo_timer_name.setText(R.string.most_demo_timer);
        most_demo_timer.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.tv_back:
                finish();
                break;
            case R.id.most_demo_manual:
                Intent manualIntent = new Intent(DemoActivity.this, ManualActivity.class);
                manualIntent.putExtra("DisplayMode","DisplayMode");
                startActivity(manualIntent);
                break;
            case R.id.most_demo_cloudy:
                Intent  cloudyIntent = new Intent(DemoActivity.this, CloudyActivity.class);
                cloudyIntent.putExtra("DisplayMode","DisplayMode");
                startActivity(cloudyIntent);
                break;
            case R.id.most_demo_lighting:
                Intent  lightingIntent = new Intent(DemoActivity.this, LightingActivity.class);
                lightingIntent.putExtra("DisplayMode","DisplayMode");
                startActivity(lightingIntent);
                break;
            case R.id.most_demo_sunrise:
                Intent sunriseIntent = new Intent(DemoActivity.this, SunriseActivity.class);
                sunriseIntent.putExtra("DisplayMode","DisplayMode");
                startActivity(sunriseIntent);
                break;
            case R.id.most_demo_timer:
                Intent timerIntent = new Intent(DemoActivity.this,TimerActivity.class);
                timerIntent.putExtra("DisplayMode","DisplayMode");
                timerIntent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                startActivity(timerIntent);
                overridePendingTransition(R.anim.slide_in_left, R.anim.slide_in_left);
                break;
        }
    }



    /**
     * 获取版本号
     * @return 当前应用的版本号
     */
    public String getVersion() {
        try {
            PackageManager manager = this.getPackageManager();
            PackageInfo info = manager.getPackageInfo(this.getPackageName(), 0);
            String version = "  V"+info.versionName;
            return this.getString(R.string.app_name) + version;
        } catch (Exception e) {
            e.printStackTrace();
            return this.getString(R.string.app_name);
        }
    }
}
